package leetcode.code201;

public class Solution extends Solution201 {

	@Override
	public int rangeBitwiseAnd(int left, int right) {
		int count = 0;
		while (left < right) {
			left >>= 1;
			right >>= 1;
			count++;
		}
		return left << count;
	}

	public static void main(String[] args) {
		int num = 2147483647;
		System.out.println(Integer.toBinaryString(num));
		System.out.println(Integer.toBinaryString(1));
		System.out.println(Integer.toBinaryString(-2));
		Solution so = new Solution();
		num = so.rangeBitwiseAnd(5, 7);
		System.out.println(num);
		num = so.rangeBitwiseAnd(1, 2147483647);
		System.out.println(num);

	}

}
